\(\int \csc ^2(c+d x) (a+b \tan (c+d x))^2 \, dx\) [27]

   Optimal result
   Rubi [A] (verified)
   Mathematica [B] (verified)
   Maple [A] (verified)
   Fricas [B] (verification not implemented)
   Sympy [F]
   Maxima [A] (verification not implemented)
   Giac [A] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 21, antiderivative size = 42 \[ \int \csc ^2(c+d x) (a+b \tan (c+d x))^2 \, dx=-\frac {a^2 \cot (c+d x)}{d}+\frac {2 a b \log (\tan (c+d x))}{d}+\frac {b^2 \tan (c+d x)}{d} \]

[Out]

-a^2*cot(d*x+c)/d+2*a*b*ln(tan(d*x+c))/d+b^2*tan(d*x+c)/d

Rubi [A] (verified)

Time = 0.06 (sec) , antiderivative size = 42, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 2, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.095, Rules used = {3597, 45} \[ \int \csc ^2(c+d x) (a+b \tan (c+d x))^2 \, dx=-\frac {a^2 \cot (c+d x)}{d}+\frac {2 a b \log (\tan (c+d x))}{d}+\frac {b^2 \tan (c+d x)}{d} \]

[In]

Int[Csc[c + d*x]^2*(a + b*Tan[c + d*x])^2,x]

[Out]

-((a^2*Cot[c + d*x])/d) + (2*a*b*Log[Tan[c + d*x]])/d + (b^2*Tan[c + d*x])/d

Rule 45

Int[((a_.) + (b_.)*(x_))^(m_.)*((c_.) + (d_.)*(x_))^(n_.), x_Symbol] :> Int[ExpandIntegrand[(a + b*x)^m*(c + d
*x)^n, x], x] /; FreeQ[{a, b, c, d, n}, x] && NeQ[b*c - a*d, 0] && IGtQ[m, 0] && ( !IntegerQ[n] || (EqQ[c, 0]
&& LeQ[7*m + 4*n + 4, 0]) || LtQ[9*m + 5*(n + 1), 0] || GtQ[m + n + 2, 0])

Rule 3597

Int[sin[(e_.) + (f_.)*(x_)]^(m_)*((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(n_), x_Symbol] :> Dist[b/f, Subst[Int
[x^m*((a + x)^n/(b^2 + x^2)^(m/2 + 1)), x], x, b*Tan[e + f*x]], x] /; FreeQ[{a, b, e, f, n}, x] && IntegerQ[m/
2]

Rubi steps \begin{align*} \text {integral}& = \frac {b \text {Subst}\left (\int \frac {(a+x)^2}{x^2} \, dx,x,b \tan (c+d x)\right )}{d} \\ & = \frac {b \text {Subst}\left (\int \left (1+\frac {a^2}{x^2}+\frac {2 a}{x}\right ) \, dx,x,b \tan (c+d x)\right )}{d} \\ & = -\frac {a^2 \cot (c+d x)}{d}+\frac {2 a b \log (\tan (c+d x))}{d}+\frac {b^2 \tan (c+d x)}{d} \\ \end{align*}

Mathematica [B] (verified)

Leaf count is larger than twice the leaf count of optimal. \(91\) vs. \(2(42)=84\).

Time = 1.40 (sec) , antiderivative size = 91, normalized size of antiderivative = 2.17 \[ \int \csc ^2(c+d x) (a+b \tan (c+d x))^2 \, dx=-\frac {\cos (c+d x) \left (a \cos (c+d x) (a \cot (c+d x)+2 b (\log (\cos (c+d x))-\log (\sin (c+d x))))-b^2 \sin (c+d x)\right ) (a+b \tan (c+d x))^2}{d (a \cos (c+d x)+b \sin (c+d x))^2} \]

[In]

Integrate[Csc[c + d*x]^2*(a + b*Tan[c + d*x])^2,x]

[Out]

-((Cos[c + d*x]*(a*Cos[c + d*x]*(a*Cot[c + d*x] + 2*b*(Log[Cos[c + d*x]] - Log[Sin[c + d*x]])) - b^2*Sin[c + d
*x])*(a + b*Tan[c + d*x])^2)/(d*(a*Cos[c + d*x] + b*Sin[c + d*x])^2))

Maple [A] (verified)

Time = 1.91 (sec) , antiderivative size = 38, normalized size of antiderivative = 0.90

method result size
derivativedivides \(\frac {b^{2} \tan \left (d x +c \right )+2 a b \ln \left (\tan \left (d x +c \right )\right )-a^{2} \cot \left (d x +c \right )}{d}\) \(38\)
default \(\frac {b^{2} \tan \left (d x +c \right )+2 a b \ln \left (\tan \left (d x +c \right )\right )-a^{2} \cot \left (d x +c \right )}{d}\) \(38\)
risch \(-\frac {2 i \left (a^{2} {\mathrm e}^{2 i \left (d x +c \right )}-b^{2} {\mathrm e}^{2 i \left (d x +c \right )}+a^{2}+b^{2}\right )}{d \left ({\mathrm e}^{2 i \left (d x +c \right )}-1\right ) \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )}+\frac {2 a b \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}-1\right )}{d}-\frac {2 a b \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )}{d}\) \(106\)

[In]

int(csc(d*x+c)^2*(a+b*tan(d*x+c))^2,x,method=_RETURNVERBOSE)

[Out]

1/d*(b^2*tan(d*x+c)+2*a*b*ln(tan(d*x+c))-a^2*cot(d*x+c))

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 96 vs. \(2 (42) = 84\).

Time = 0.27 (sec) , antiderivative size = 96, normalized size of antiderivative = 2.29 \[ \int \csc ^2(c+d x) (a+b \tan (c+d x))^2 \, dx=-\frac {a b \cos \left (d x + c\right ) \log \left (\cos \left (d x + c\right )^{2}\right ) \sin \left (d x + c\right ) - a b \cos \left (d x + c\right ) \log \left (-\frac {1}{4} \, \cos \left (d x + c\right )^{2} + \frac {1}{4}\right ) \sin \left (d x + c\right ) + {\left (a^{2} + b^{2}\right )} \cos \left (d x + c\right )^{2} - b^{2}}{d \cos \left (d x + c\right ) \sin \left (d x + c\right )} \]

[In]

integrate(csc(d*x+c)^2*(a+b*tan(d*x+c))^2,x, algorithm="fricas")

[Out]

-(a*b*cos(d*x + c)*log(cos(d*x + c)^2)*sin(d*x + c) - a*b*cos(d*x + c)*log(-1/4*cos(d*x + c)^2 + 1/4)*sin(d*x
+ c) + (a^2 + b^2)*cos(d*x + c)^2 - b^2)/(d*cos(d*x + c)*sin(d*x + c))

Sympy [F]

\[ \int \csc ^2(c+d x) (a+b \tan (c+d x))^2 \, dx=\int \left (a + b \tan {\left (c + d x \right )}\right )^{2} \csc ^{2}{\left (c + d x \right )}\, dx \]

[In]

integrate(csc(d*x+c)**2*(a+b*tan(d*x+c))**2,x)

[Out]

Integral((a + b*tan(c + d*x))**2*csc(c + d*x)**2, x)

Maxima [A] (verification not implemented)

none

Time = 0.36 (sec) , antiderivative size = 39, normalized size of antiderivative = 0.93 \[ \int \csc ^2(c+d x) (a+b \tan (c+d x))^2 \, dx=\frac {2 \, a b \log \left (\tan \left (d x + c\right )\right ) + b^{2} \tan \left (d x + c\right ) - \frac {a^{2}}{\tan \left (d x + c\right )}}{d} \]

[In]

integrate(csc(d*x+c)^2*(a+b*tan(d*x+c))^2,x, algorithm="maxima")

[Out]

(2*a*b*log(tan(d*x + c)) + b^2*tan(d*x + c) - a^2/tan(d*x + c))/d

Giac [A] (verification not implemented)

none

Time = 0.46 (sec) , antiderivative size = 51, normalized size of antiderivative = 1.21 \[ \int \csc ^2(c+d x) (a+b \tan (c+d x))^2 \, dx=\frac {2 \, a b \log \left ({\left | \tan \left (d x + c\right ) \right |}\right ) + b^{2} \tan \left (d x + c\right ) - \frac {2 \, a b \tan \left (d x + c\right ) + a^{2}}{\tan \left (d x + c\right )}}{d} \]

[In]

integrate(csc(d*x+c)^2*(a+b*tan(d*x+c))^2,x, algorithm="giac")

[Out]

(2*a*b*log(abs(tan(d*x + c))) + b^2*tan(d*x + c) - (2*a*b*tan(d*x + c) + a^2)/tan(d*x + c))/d

Mupad [B] (verification not implemented)

Time = 4.56 (sec) , antiderivative size = 44, normalized size of antiderivative = 1.05 \[ \int \csc ^2(c+d x) (a+b \tan (c+d x))^2 \, dx=\frac {b^2\,\mathrm {tan}\left (c+d\,x\right )}{d}-\frac {a^2}{d\,\mathrm {tan}\left (c+d\,x\right )}+\frac {2\,a\,b\,\ln \left (\mathrm {tan}\left (c+d\,x\right )\right )}{d} \]

[In]

int((a + b*tan(c + d*x))^2/sin(c + d*x)^2,x)

[Out]

(b^2*tan(c + d*x))/d - a^2/(d*tan(c + d*x)) + (2*a*b*log(tan(c + d*x)))/d